From: Keir Fraser Date: Fri, 19 Jun 2009 07:41:50 +0000 (+0100) Subject: IOMMU: Add two generic functions to vendor neutral interface X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13726 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=0506bc4d892b7716daa80a24f82f6660252b9f06;p=xen.git IOMMU: Add two generic functions to vendor neutral interface Add 2 generic functions into the vendor neutral iommu interface, The reason is that from changeset 19732, there is only one global flag "iommu_enabled" that controls iommu enablement for both vtd and amd systems, so we need different code paths for vtd and amd iommu systems if this flag has been turned on. Also, the early checking of "iommu_enabled" in iommu_setup() is removed to prevent iommu functionalities from been disabled on amd systems. Signed-off-by: Wei Wang --- diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index 2de803d6d0..3bd8fa90d4 100644 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -192,7 +192,7 @@ static void read_msi_msg(struct msi_desc *entry, struct msi_msg *msg) } if ( iommu_enabled ) - msi_msg_read_remap_rte(entry, msg); + iommu_read_msi_from_ire(entry, msg); } static int set_vector_msi(struct msi_desc *entry) diff --git a/xen/drivers/passthrough/amd/iommu_intr.c b/xen/drivers/passthrough/amd/iommu_intr.c index 5ca5f16eaf..18c494b379 100644 --- a/xen/drivers/passthrough/amd/iommu_intr.c +++ b/xen/drivers/passthrough/amd/iommu_intr.c @@ -231,6 +231,18 @@ void amd_iommu_msi_msg_update_ire( update_intremap_entry_from_msi_msg(iommu, pdev, msg); } +unsigned int amd_iommu_read_ioapic_from_ire( + unsigned int apic, unsigned int reg) +{ + *IO_APIC_BASE(apic) = reg; + return *(IO_APIC_BASE(apic)+4); +} + +void amd_iommu_read_msi_from_ire( + struct msi_desc *msi_desc, struct msi_msg *msg) +{ +} + int __init deallocate_intremap_table(void) { if ( int_remap_table ) diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index e23f5e8e2f..83e25ed231 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -439,4 +439,6 @@ struct iommu_ops amd_iommu_ops = { .get_device_group_id = amd_iommu_group_id, .update_ire_from_apic = amd_iommu_ioapic_update_ire, .update_ire_from_msi = amd_iommu_msi_msg_update_ire, + .read_apic_from_ire = amd_iommu_read_ioapic_from_ire, + .read_msi_from_ire = amd_iommu_read_msi_from_ire, }; diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index daab8c9b20..51e15e5b09 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -263,14 +263,10 @@ static int iommu_setup(void) { int rc = -ENODEV; - if ( !iommu_enabled ) - goto out; - rc = iommu_hardware_setup(); iommu_enabled = (rc == 0); - out: if ( force_iommu && !iommu_enabled ) panic("IOMMU setup failed, crash Xen for security purpose!\n"); @@ -336,6 +332,20 @@ void iommu_update_ire_from_msi( struct iommu_ops *ops = iommu_get_ops(); ops->update_ire_from_msi(msi_desc, msg); } + +void iommu_read_msi_from_ire( + struct msi_desc *msi_desc, struct msi_msg *msg) +{ + struct iommu_ops *ops = iommu_get_ops(); + ops->read_msi_from_ire(msi_desc, msg); +} + +unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg) +{ + struct iommu_ops *ops = iommu_get_ops(); + return ops->read_apic_from_ire(apic, reg); +} + /* * Local variables: * mode: C diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index e27e6dbf04..a163a46508 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1989,6 +1989,8 @@ struct iommu_ops intel_iommu_ops = { .get_device_group_id = intel_iommu_group_id, .update_ire_from_apic = io_apic_write_remap_rte, .update_ire_from_msi = msi_msg_write_remap_rte, + .read_apic_from_ire = io_apic_read_remap_rte, + .read_msi_from_ire = msi_msg_read_remap_rte, }; /* diff --git a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h index 1722c340da..edc8968d35 100644 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h @@ -87,6 +87,10 @@ void amd_iommu_ioapic_update_ire( unsigned int apic, unsigned int reg, unsigned int value); void amd_iommu_msi_msg_update_ire( struct msi_desc *msi_desc, struct msi_msg *msg); +void amd_iommu_read_msi_from_ire( + struct msi_desc *msi_desc, struct msi_msg *msg); +unsigned int amd_iommu_read_ioapic_from_ire( + unsigned int apic, unsigned int reg); static inline u32 get_field_from_reg_u32(u32 reg_value, u32 mask, u32 shift) { diff --git a/xen/include/asm-x86/io_apic.h b/xen/include/asm-x86/io_apic.h index b4fba09d72..14cca8d9ed 100644 --- a/xen/include/asm-x86/io_apic.h +++ b/xen/include/asm-x86/io_apic.h @@ -131,7 +131,7 @@ extern int mpc_default_type; static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) { if (ioapic_reg_remapped(reg)) - return io_apic_read_remap_rte(apic, reg); + return iommu_read_apic_from_ire(apic, reg); *IO_APIC_BASE(apic) = reg; return *(IO_APIC_BASE(apic)+4); } diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 525c176396..8300525286 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -107,10 +107,14 @@ struct iommu_ops { int (*get_device_group_id)(u8 bus, u8 devfn); void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value); void (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg); + void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg); + unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg); }; void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value); void iommu_update_ire_from_msi(struct msi_desc *msi_desc, struct msi_msg *msg); +void iommu_read_msi_from_ire(struct msi_desc *msi_desc, struct msi_msg *msg); +unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg); void iommu_suspend(void); void iommu_resume(void);